﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using AGDN;

namespace Sudum
{
    enum BulletSource
    {
        Player,   // this bullet from player
        Enemy     // this bullet fired by an enemy
    }

    class Bullet
    {
        Vector3 initialPosition;
        Vector3 position;
        Vector3 direction;
        const float kBulletSpeed = 0.016f;
        const float kSpeedModifier = 20;
        BulletSource bulletSource;
        bool Alive;

        public Bullet(Vector3 pos, Vector3 dir, BulletSource bs)
        {
            bulletSource = bs;

            initialPosition = pos;
            position = pos;

            dir.Normalize();
            direction = dir;

            Alive = true;
        }

        public void Update()
        {
            // update bullet position here by moving the bullet by speed in the bullet direction
            position += kBulletSpeed * kSpeedModifier * direction;

            // kill bullet
            if ((position - initialPosition).Length() > GameLevel.Current().GetTubeLength())
                Alive = false;
        }

        public Vector3 GetPosition()
        {
            return position;
        }

        public bool IsAlive()
        {
            return Alive;
        }
        public BulletSource GetSource()
        {
            return bulletSource;
        }

    }
}
